home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
10615
/
10615.xpi
/
chrome
/
firedownload.jar
/
content
/
downloads-overlay.js
next >
Wrap
Text File
|
2009-06-17
|
3KB
|
87 lines
//@line 2 "z:\Development\moztrunk\src\extensions\firedownload\chrome\content\downloads-overlay.js"
var FireDownloadManager = {
defaultPauseFunction : null,
defaultResumeFunction : null,
defaultCancelFunction : null,
defaultRetryFunction : null,
defaultCreateDownloadItem : null,
useFieryBar : true,
init : function fdm_init() {
//@line 18 "z:\Development\moztrunk\src\extensions\firedownload\chrome\content\downloads-overlay.js"
FireDownloadManager.defaultPauseFunction = window.pauseDownload;
window.pauseDownload = function(aDownload) {
var download = FireDownloadManager.getFireDownload(aDownload);
if (download) {
download.pauseDownload();
aDownload.setAttribute("state", Ci.nsIDownloadManager.DOWNLOAD_PAUSED);
}
else {
FireDownloadManager.defaultPauseFunction(aDownload);
}
}
FireDownloadManager.defaultResumeFunction = window.resumeDownload;
window.resumeDownload = function(aDownload) {
var download = FireDownloadManager.getFireDownload(aDownload);
if (download) {
download.resumeDownload();
aDownload.setAttribute("state", Ci.nsIDownloadManager.DOWNLOAD_DOWNLOADING);
}
else {
FireDownloadManager.defaultResumeFunction(aDownload);
}
}
FireDownloadManager.defaultCancelFunction = window.cancelDownload;
window.cancelDownload = function(aDownload) {
var download = FireDownloadManager.getFireDownload(aDownload);
if (download) {
aDownload.setAttribute("firedownload", download.URL);
}
FireDownloadManager.defaultCancelFunction(aDownload);
}
FireDownloadManager.defaultRetryFunction = window.retryDownload;
window.retryDownload = function(aDownload) {
var url = aDownload.getAttribute("firedownload");
if (url && url != "") {
removeFromView(aDownload);
download = Cc["@mozilla.org/firedownload;1"].createInstance(Ci.nsIFireDownload);
download.startDownload(url, "");
}
else {
FireDownloadManager.defaultRetryFunction(aDownload);
}
}
FireDownloadManager.defaultCreateDownloadItem = window.createDownloadItem;
window.createDownloadItem = function(aAttrs) {
var dl = FireDownloadManager.defaultCreateDownloadItem(aAttrs);
if (dl) {
var download = FireDownloadManager.getFireDownload(dl);
if (download && FireDownloadManager.useFieryBar) {
dl.setAttribute("firedownload", "true");
}
}
return dl;
}
},
getFireDownload : function fdm_getFireDownload(aDownload) {
var dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
var id = aDownload.getAttribute("dlid");
var download = dm.getDownload(id);
if (download.cancelable instanceof Ci.nsIFireDownload) {
return download.cancelable.QueryInterface(Ci.nsIFireDownload);
}
else {
return null;
}
}
};
window.addEventListener("load", function(e) { FireDownloadManager.init(); }, false);